<?php
session_start();

$id = $_POST['program'];

include ($_SERVER['DOCUMENT_ROOT'].'/insp-modules/misc/config.php');

$link = mysqli_connect($host, $user, $password, "eventfeedback");

if (mysqli_connect_errno()) {
	printf("Connect Error!");
	exit();
}

$query = "CALL GetProgramsByID('$id')";
if (mysqli_multi_query($link, $query)) {
	if ($result = mysqli_use_result($link)) {
		while ($row = mysqli_fetch_assoc($result)) {
			$event_info_json = json_encode($row);
			$_SESSION['event_info_json'] = $event_info_json;
			// echo print_r($_SESSION['event_info_json']);
		}
	}
	if (mysqli_next_result($link)) {
		mysqli_free_result($result);
	}
}

$query = "CALL GetQuestions()";
if (mysqli_multi_query($link, $query)) {
	if ($result = mysqli_use_result($link)) {
		$questions = array();
		while ($row = mysqli_fetch_assoc($result)) {
			array_push($questions, $row);	
		}
		$question_json = json_encode($questions);
		// echo print_r($question_json);
		$_SESSION['question_json'] = $question_json;
		// echo print_r($_SESSION['question_json']);
	}
	if (mysqli_next_result($link)) {
		mysqli_free_result($result);
	}
}

header('location: home.php#tabs-2');
?>